package FWK.components;

import java.awt.Cursor;
import java.io.IOException;

import javax.swing.JMenuItem;

import org.apache.log4j.Logger;

import FWK.core.FwkErrorMannager;
import FWK.util.FwkMessageManager;
import FWK.util.FwkViewsUtils;

public class FwkMenuItem extends JMenuItem implements FwkComponent{
	private static Logger logger = Logger.getLogger(FwkMenuItem.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = 6950884769813030848L;

	public FwkMenuItem(int key, String pathImage,
			String tooltip, String propertyMessage) {
		
		String message = FwkMessageManager.getInstance().getProperty(
				propertyMessage);

		this.setMnemonic(key);
		this.setText(message);
		try {
			this.setIcon(FwkViewsUtils.getIcon(pathImage, 15, 15));
		} catch (IOException e) {
			FwkErrorMannager.error(e, "No se pueden cargar las imagenes", null);
		}
		setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
		if (tooltip == null || tooltip.trim().equals("")) {
			this.setToolTipText(message);
		} else {
			this.setToolTipText(tooltip);
		}
	}

	@Override
	public void activate() {
		this.setEnabled(true);
		
	}

	@Override
	public void standBy() {
		this.setEnabled(false);		
	}
}
